import { Routes, Route } from "react-router-dom";
import Home from "@/pages/Home";
import Dashboard from "@/pages/Dashboard";
import MyProjects from "@/pages/MyProjects";
import Navbar from "@/components/Navbar";
import { useState } from "react";
import { AuthContext, UserInfo } from '@/contexts/authContext';

export default function App() {
  const [isAuthenticated, setIsAuthenticated] = useState(true); // 默认已登录，方便演示
  const [userInfo, setUserInfo] = useState<UserInfo | null>({
    id: "user123",
    username: "创意达人",
    avatar: "https://space.coze.cn/api/coze_space/gen_image?image_size=square&prompt=user%20avatar%20profile%20picture&sign=a47ca4238b884af3e5f2e2dfbbcc7eb9",
    email: "user@example.com"
  });

  const logout = () => {
    setIsAuthenticated(false);
    setUserInfo(null);
  };

  return (
    <AuthContext.Provider
      value={{ isAuthenticated, userInfo, setIsAuthenticated, setUserInfo, logout }}
    >
      <div className="min-h-screen flex flex-col">
        <Navbar />
        <main className="flex-1 py-6 px-4 md:px-8">
          <Routes>
            <Route path="/" element={<Home />} />
            <Route path="/dashboard" element={<Dashboard />} />
            <Route path="/my-projects" element={<MyProjects />} />
          </Routes>
        </main>
      </div>
    </AuthContext.Provider>
  );
}